package com.example.yls.demoa;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;

public class MyService extends Service {
    private static final String TAG = "MyService";
    private Boolean isLive=true;
    private MyBind myBind;
    @Override
    public IBinder onBind(Intent intent) {
        return  myBind;
    }


    @Override
    public void onCreate() {

        super.onCreate();

          myBind=new MyBind();

            new Thread(new Runnable() {
                @Override
                public void run() {
                    while (isLive){
                        try {
                            Log.e(TAG, "onCreate: "+System.currentTimeMillis() );

                            Thread.sleep(2000);

                        }
                        catch (InterruptedException e){
                            e.printStackTrace();
                        }
                    }
                }
            }).start();



    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        return super.onStartCommand(intent, flags, startId);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        isLive=false;
        Log.e(TAG, "onDestroy:" );
    }


}
